import java.util.Comparator;
import java.util.PriorityQueue;

public class Solution1792 {
    public double maxAverageRatio(int[][] classes, int extraStudents) {
        PriorityQueue<int[]> priorityQueue=new PriorityQueue<>(Comparator.comparingDouble(a->(-1)*(double)(a[1]-a[0])/((long)a[1]*(a[1]+1))));
        for (int[] aClass : classes) {
            priorityQueue.offer(aClass);
        }
        for (int i = 0; i < extraStudents; i++) {
            int[] t=priorityQueue.poll();
            priorityQueue.offer(new int[]{t[0]+1,t[1]+1});
        }
        double ans=0;
        while (!priorityQueue.isEmpty()){
            int[] t=priorityQueue.poll();
            ans+= 1.0*t[0]/t[1];
        }
        ans/=classes.length;
        return ans;
    }

    public static void main(String[] args) {
        System.out.println(new Solution1792().maxAverageRatio(new int[][]{{1,2},{3,5},{2,2}},2));
    }
}
